home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1993…ch: Other People's Memory / ADC Developer CD (1993-03) (''Other People's Memory'')_iso / Dev.CD Mar 93.iso / Development Platforms / Apple II / Essentials / Technical.Notes / IIGS / TN.IIGS.076 < prev    next >
Encoding:
Text File  |  1992-07-15  |  16.6 KB  |  426 lines  |  [TEXT/GEOL]

  1. Apple II
  2. Technical Notes
  3. _____________________________________________________________________________
  4.                                                   Developer Technical Support
  5. Apple IIgs
  6. #76: Miscellaneous Resource Formats
  7.  
  8. Revised by: Matt Deatherage                                          May 1992
  9. Written by: Matt Deatherage, C.K. Haun, Llew Roberts             January 1990
  10.             & Dave Lyons
  11.  
  12. This Technical Note describes resource structure formats for
  13. previously-unpublished types.
  14.  
  15. CHANGES SINCE DECEMBER 1991:  Added information on rFont resources.  Clarified
  16. the note about rVersion resources to note that version numbers must increase
  17. with subsequent releases for the Finder's benefit.
  18. _____________________________________________________________________________
  19.  
  20.  
  21. The format used to describe the resources is similar to that used in File Type
  22. Notes, where the offsets, given in the form (+xxx), determine the offset from
  23. the beginning of the resource.
  24.  
  25.  
  26. SAMPLED SOUND RESOURCE (TYPE: $8024, RSOUNDSAMPLE)
  27.  
  28. The following describes the Sampled Sound resource format. It consists of a
  29. ten-byte header followed by the sample data bytes.
  30.  
  31.    Format        (+000)  Word    This must always be zero.
  32.    Wave Size     (+002)  Word    Sample size in pages (256 bytes per page).
  33.                                  For example, an 8K sample takes 32 pages; a
  34.                                  128K sample requires $200 pages.
  35.    Rel Pitch     (+004)  Word    The high byte of this word is a semitone
  36.                                  value; the low byte is a fractional
  37.                                  semitone. These values are used to tune the
  38.                                  sample to correct pitch. See HyperCard IIgs
  39.                                  Technical Note #3, Pitching Sampled Sound.
  40.    Stereo        (+006)  Word    The output channel for this sound is in the
  41.                                  low nibble of this word.
  42.    Sample rate   (+008)  Word    The sampling rate of the sound, in Hertz
  43.                                  (Hz).
  44.    Sound         (+010)  Bytes   The sampled sound data. The bytes are all
  45.                                  8-bit samples. The sample starts here and
  46.                                  continues until the end of the resource.
  47.  
  48. The resource compiler template follows:
  49.  
  50. #define rSoundSample     $8024
  51.  
  52. /*---------------------- rSoundSample --------------------*/
  53. type rSoundSample {
  54.      integer;            /* format */
  55.      integer;            /* wave size */
  56.      hex integer;        /* rel pitch */
  57.      integer;            /* stereo channel */
  58.      unsigned integer;   /* sample rate */
  59.      hex string;         /* raw 8 bit sound data */
  60. };
  61.  
  62.  
  63. CURSOR RESOURCE (TYPE: $8027, RCURSOR)
  64.  
  65. The following describes the Cursor resource format:
  66.  
  67.    height   (+000)   Word  The height of the cursor, in pixels.
  68.    width    (+002)   Word  The width of the cursor, in Words.
  69.    image    (+004)   Bytes The image of the cursor. There are height*width
  70.                      Words in the cursor, or twice that many Bytes.
  71.  
  72.    We will call the first byte beyond the image offset "ei" for "end of
  73.    image."
  74.  
  75.    mask     (+ei)    Bytes The mask of the cursor. This is the same size as
  76.                      the image.
  77.  
  78.    We will call the first byte beyond the mask offset "em" for "end of mask."
  79.  
  80.    hotSpotY (+em)    Word  The cursor's Y "hot spot."
  81.    hotSpotX (+em+2)  Word  The cursor's X "hot spot."
  82.    flags    (+em+4)  Flag  Cursor flags:
  83.                            Bit 7: 1 = 640 Mode, 0 = 320 Mode
  84.                            All other bits are reserved and must be zero.
  85.    reserved (+em+6) 8 Bytes Reserved, must be zero.
  86.  
  87. The resource compiler template follows:
  88.  
  89. #define rCursor     $8027
  90.  
  91. /*---------------------- rCursor --------------------*/
  92. type rCursor {
  93.     height :
  94.         hex integer;            /* height */
  95.     width :
  96.         hex integer;            /* width in words */
  97.         hex string[2*$$Word(height)*$$Word(width)];    /* cursor image */
  98.         hex string[2*$$Word(height)*$$Word(width)];    /* cursor mask */
  99.         hex integer;            /* hotspot Y */
  100.         hex integer;            /* hotspot X */
  101.         hex integer;            /* flags */
  102.         hex longint = 0;        /* reserved */
  103.         hex longint = 0;        /* reserved */
  104.     };
  105. };
  106. Following is a simple cursor example:
  107.  
  108. resource rCursor(1,fixed) {
  109.         5,     /* height */
  110.         2,     /* width */
  111.         $"ffff0000"
  112.         $"f00f0000"
  113.         $"f00f0000"
  114.         $"f00f0000"
  115.         $"ffff0000",
  116.  
  117.         $"ffff0000"
  118.         $"ffff0000"
  119.         $"ffff0000"
  120.         $"ffff0000"
  121.         $"ffff0000",
  122.  
  123.         2,     /* hotspot Y */
  124.         2,     /* hotspot X */
  125.         $80    /* 640 mode */
  126. };
  127.  
  128. Note that the resource is marked fixed so that its handle can be dereferenced
  129. and passed to SetCursor.
  130.  
  131.  
  132. VERSION RESOURCE (TYPE: $8029, RVERSION)
  133.  
  134. Files may include a version resource with ID=1 for display by programs such as
  135. the Finder. All rVersion resource IDs other than 1 are reserved for future
  136. definition. The following describes the version resource format:
  137.  
  138.    version       (+000)   Long    The application's version number, in Apple
  139.                                   IIgs Long Version format. See Apple IIgs
  140.                                   Technical Note #100, VersionVille, for more
  141.                                   details.
  142.    country       (+004)   Word    An international country version code.
  143.                                   Possible values are as follows:
  144.  
  145.                                               verUS          0
  146.                                               verFrance      1
  147.                                               verBritain     2
  148.                                               verGermany     3
  149.                                               verItaly       4
  150.                                               verNetherlands 5
  151.                                               verBelgiumLux  6
  152.                                               verSweden      7
  153.                                               verSpain       8
  154.                                               verDenmark     9
  155.                                               verPortugal    10
  156.                                               verFrCanada    11
  157.                                               verNorway      12
  158.                                               verIsrael      13
  159.                                               verJapan       14
  160.                                               verAustralia   15
  161.                                               verArabia      16
  162.                                               verFinland     17
  163.                                               verFrSwiss     18
  164.                                               verGrSwiss     19
  165.                                               verGreece      20
  166.                                               verIceland     21
  167.                                               verMalta       22
  168.                                               verCyprus      23
  169.                                               verTurkey      24
  170.                                               verYugoslavia  25
  171.                                               verIreland     50
  172.                                               verKorea       51
  173.                                               verChina       52
  174.                                               verTaiwan      53
  175.                                               verThailand    54
  176.  
  177.    name          (+006)   String  Pascal string containing the desired name.
  178.                                   May be the null string.
  179.    moreInfo      (+xxx)   String  Additional information to be displayed,
  180.                           such as a copyright notice. May be the null string.
  181.                           Recommended maximum length is about two lines of 35
  182.                           characters each. May contain a carriage return
  183.                           (character $0D).
  184.  
  185. The resource compiler template follows:
  186.  
  187. #define rVersion    $8029
  188.  
  189. // Equates for the country code of an rVersion resource
  190.  
  191. #define Region \
  192.    verUS, verFrance, verBritain, verGermany,
  193.    verItaly, verNetherlands, verBelgiumLux,
  194.    verFrBelgiumLux = 6, verSweden, verSpain,
  195.    verDenmark, verPortugal, verFrCanada, verNorway,
  196.    verIsrael, verJapan, verAustralia, verArabia,
  197.    verArabic=16, verFinland, verFrSwiss, verGrSwiss,
  198.    verGreece, verIceland, verMalta, verCyprus,
  199.    verTurkey, verYugoslavia, verYugoCroatian = 25,
  200.    verIndia = 33, verIndiaHindi = 33, verPakistan,
  201.    verLithuania = 41, verPoland, verHungary,
  202.    verEstonia, verLatvia, verLapland, verFaeroeIsl,
  203.    verIran, verRussia, verIreland = 50, verKorea,
  204.    verChina, verTaiwan, verThailand
  205.  
  206. /*------------------- rVersion ------------------*/
  207. type rVersion {
  208.      ReverseBytes {
  209.           hex byte;                            // Major revision in BCD
  210.           hex bitstring[4];                    // Minor vevision in BCD
  211.           hex bitstring[4];                    // Bug version
  212.           hex byte  development = 0x20,        // Release stage
  213.                          alpha = 0x40,
  214.                          beta = 0x60,
  215.                          final = 0x80, /* or */ release = 0xA0;
  216.           hex byte;                          // Non-final release #
  217.      };
  218.      integer   Region;                        // Region code
  219.      pstring;                                 // Short version number
  220.      pstring;                                 // Long version number
  221. };
  222.  
  223. Following is a simple version example for "Super Graphics Destroyer", version
  224. 2.0:
  225.  
  226. resource rVersion(1) {
  227.        { $02,$0,$0,release,$00 },       /* version 2.0 release */
  228.      verUS,                        /* US version */
  229.      "Super Graphics Destroyer",        /* our app's name */
  230.      "(C) 1991 Pretty as a Picture, Inc."    /* the copyright notice */
  231. };
  232.  
  233.    NOTE: For compatibility with the Finder, keep the name field
  234.          identical across different versions of the same
  235.          application, and make sure the version field increases on
  236.          each later version released to your customers. The
  237.          moreInfo field is not critical; if it changes between
  238.          versions, it's no big deal.
  239.  
  240.  
  241. COMMENT RESOURCE (TYPE: $802A, RCOMMENT)
  242.  
  243. Files may include a comment resource with ID=1 for display by programs such as
  244. the Finder. All rComment resource IDs other than 1 are reserved for future
  245. definition. The following describes the comment resource format:
  246.  
  247.    text       (+000)   Bytes     The comment. This is unformatted, 8-bit text
  248.                                  suitable for displaying by a desktop
  249.                                  program. No length limit is imposed by this
  250.                                  resource format, although a practical limit
  251.                                  of a few hundred characters is recommended.
  252.  
  253. The resource compiler template follows:
  254.  
  255. #define rComment    $802A
  256.  
  257. /*---------------------- rComment --------------------*/
  258. type rComment {
  259.     string;
  260. };
  261.  
  262.  
  263. TAGGED STRINGS RESOURCE (TYPE: $802E, RTAGGEDSTRINGS)
  264.  
  265. A tagged strings resource lists pairs of Word values and Pascal strings.
  266.  
  267.    count        (+000)    Word    Number of word/string pairs in this
  268.                                    resource.
  269.    firstWord    (+002)    Word    Word value of first pair.
  270.    firstString  (+004)    String  Pascal string of first pair.
  271.    secondWord   (+xxx)    Word    Word value of second pair.
  272.    secondString (+yyy)    String  Pascal string of second pair.
  273.    ...
  274.  
  275. The resource compiler template follows:
  276.  
  277. #define rTaggedStrings        $802E
  278.  
  279. /*------------------- rTaggedStrings --------------------*/
  280.  
  281. type rTaggedStrings {
  282.           integer = $$Countof(StringArray);
  283.           array StringArray {
  284.                     hex integer;        /* Key integer */
  285.                     pstring;            /* String */
  286.           };
  287. };
  288.  
  289. Following is a simple rTaggedStrings example:
  290.  
  291. resource rTaggedStrings(1) {{
  292.      $0050, "red",
  293.      $0033, "green",
  294.      $0100, "blue"
  295. }};
  296.  
  297.  
  298. PATTERN LIST RESOURCE (TYPE: $802F, RPATTERNLIST)
  299.  
  300. A pattern list resource contains zero of more 32-byte QuickDraw II patterns.
  301. (This resource type exists for your convenience. The System Software contains
  302. no direct support for resources of this type.)
  303.  
  304. firstPattern   (+000)    32 Bytes  First QuickDraw II pattern structure.
  305. secondPattern  (+032)    32 Bytes  Second QuickDraw II pattern structure.
  306. ...
  307.  
  308.  
  309. The resource compiler template follows:
  310.  
  311. #define rPatternList          $802F
  312.  
  313. /*-------------------- rPatternList ---------------------*/
  314.  
  315. type rPatternList {
  316.      array {
  317.           array[32] {
  318.                hex byte;
  319.           };
  320.      };
  321. };
  322.  
  323.  
  324. RECTANGLE LIST RESOURCE (TYPE:  $C001, RRECTLIST)
  325.  
  326. The rectangle list (type rRectList) is provided to allow an extensible, easily
  327. modifiable collection of QuickDraw II rectangle structures. This capability
  328. can enhance a developer's ability to modify on-screen displays without
  329. recompiling an entire application. This resource also enables easier
  330. cross-development and parallel development for the Apple IIgs and the
  331. Macintosh.
  332.  
  333. The following describes the rectangle list resource format:
  334.  
  335. count          (+000)    Word      Number of rectangles in this resource.
  336. firstRectangle (+002)    8 Bytes   First QuickDraw II rectangle structure.
  337.                 ...                Rectangles, eight bytes each.
  338. lastRectangle  (+002+(8*(count-1)))
  339.                          8 Bytes   Last QuickDraw II rectangle structure.
  340.  
  341.  
  342. The resource compiler template follows:
  343.  
  344. #define rRectList    $C001
  345. type rRectList {
  346.         integer = $$Countof(RectArray);
  347.         array RectArray {
  348.             Rect;
  349.             };
  350. };
  351.  
  352.  
  353. PRINT RECORD RESOURCE (TYPE: $C002, RPRINTRECORD)
  354.  
  355. As a convenience for applications, a print record may be included as a
  356. resource of type $C002 (rPrintRecord). If more than one of these resources is
  357. present, the one to use as the document's primary print record is the first
  358. one. You can get this resource's ID by calling GetIndResource with type
  359. rPrintRecord and index 1. Storing the primary print record with ID = 1 is a
  360. good way to start.
  361.  
  362. Since the print record is filled in and interpreted by the printer driver, you
  363. can't always programmatically set options that are driver-specific. For
  364. example, although the ImageWriter driver stores the color-vs.-black and white
  365. option in one place, not all color printers will do the same thing. If you
  366. want to use driver-specific options on many printers, you can use those
  367. printer drivers to create print record that reflect the options you want and
  368. store those records as resources. Then, if you need a pre-initialized print
  369. record with the options you want, you may already have one.
  370.  
  371.    print record  (+000)  160 Bytes  The print record. The handle to this
  372.                                     resource is suitable for passing to any
  373.                                     Print Manager call that requires a print
  374.                                     record handle.
  375.  
  376. Since applications shouldn't create print records from scratch, but rather
  377. allow printer drivers to fill them in with PrDefault and PrVerify, the
  378. resource compiler template that follows only allocates 160 bytes for storage.
  379.  
  380. #define rPrintRecord     $C002
  381.  
  382. /*-------------------- rPrintRecord ------------------*/
  383. type rPrintRecord {
  384.      array[160] {
  385.           hex byte;
  386.      };
  387. };
  388.  
  389.  
  390. FONT RESOURCE (TYPE: $C003, RFONT)
  391.  
  392. Some applications wish to keep fonts with the application itself instead of in
  393. a separate font file.  This isn't always advisable--fonts not in font files
  394. can't be easily used in other applications, which may confuse users who, for
  395. example, use text-editing desk accessories and can't get at certain fonts
  396. except in certain applications.  Also, fonts not in the Fonts directory must
  397. be completely memory-resident where normal Fonts are only loaded from disk
  398. when they're needed.
  399.  
  400. Nevertheless, in some cases keeping fonts inside an application file is
  401. necessary or desirable.  In such cases, the rFont resource is a convenient way
  402. to keep a font around.  The resource is a QuickDraw II Font, as defined in
  403. Apple IIgs Toolbox Reference, Volume 2.  The font family name is the
  404. resource's name--the same Pascal string that normally precedes the QuickDraw
  405. II font record in the font file.
  406.  
  407.    font  (+000)  Bytes     The font record, without the font family name.
  408.  
  409. Since the font record is a bunch of variable-sized tables, and since you
  410. probably want to use a font editor (and not the resource compiler) to create
  411. fonts, the following resource compiler template isn't very revealing.
  412.  
  413. /*-------------------- rFont ------------------*/
  414.  
  415. type rFont {
  416.      hex string;
  417. };
  418.  
  419.  
  420. Further Reference
  421. _____________________________________________________________________________
  422.  
  423.    o   Apple IIgs Toolbox Reference, Volumes 1-3
  424.    o   Apple IIgs Technical Note #100, VersionVille
  425.    o   HyperCard IIgs Technical Note #3, Pitching Sampled Sounds
  426.